#ifndef ASCE_LOGGING_H_
#define ASCE_LOGGING_H_
#include "asce_config.h"
#include "file.h"
#include "mutex.h"

namespace asce
{
	enum LogSevervity
	{
		LOG_INFO = 0,
		LOG_WARNING = 1,
		LOG_ERROR = 2,
	};

	class Logging
	{
	public:
		static Logging&	Instance();

	public:
		void	Write(LogSevervity severiry, char* format, ...);

	public:
		void	OpenToStdErr();
		void	CloseToStdErr();
		bool	ToStdErr();
		void	SetMaxLogSize(uint32 size);
		uint32	GetMaxLogSize();

	public:
		LogSevervity	FileSeveriry();
		void			SetFileSeverity(LogSevervity severity);
		LogSevervity	StderrSeverity();
		void			SetStderrSeveriry(LogSevervity severity);

	private:
		Logging();
		~Logging();

	private:
		std::string		GetNowTime();
		bool			CreatFile();

	private:
		File		file_;
		bool		disk_full_;
		uint32		max_log_size_;	//MB
		Mutex		mutex_;
		bool		to_stderr_;
		std::string dir_;
		LogSevervity	file_severity_;
		LogSevervity	stderr_severity_;

	private:
		static char* log_info[LOG_ERROR+1];
	};
}

#endif